﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using App.Core.Extensions;
using App.Data;

public partial class Pages_Admin_NewsletterList : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BindPageInfo();
        if (!IsPostBack)
        {
            BindNewsletterList(1);
        }
    }
    protected void BindPageInfo()
    {
        Page.Title = WebUtil.GetPageTitle("Newsletter List");
    }

    protected void BindNewsletterList(int pageNumber)
    {
        int totalRecord = 0;
        UtilityDAO dao = new UtilityDAO();
        DataSet ds = dao.GetPagedData(AppSQL.GET_NEWSLETTER_LIST, null, pageNumber, ConfigReader.NewsLetterListSize, out totalRecord);

        ucNewsletterList.DataSource = ds.Tables[0];
        ucNewsletterList.EditLink = AppConstants.Pages.NEWSLETTER_CHANGE + "?" + AppConstants.QueryString.ID + "={0}";        
        ucNewsletterList.DataBind();

        ///Bind Pager
        ucNewsletterListPager.TotalRecord = totalRecord;
        ucNewsletterListPager.PageNo = pageNumber;
        ucNewsletterListPager.PageSize = ConfigReader.NewsLetterListSize;
        ucNewsletterListPager.TotalRecordMessage = "Total {0} Newsletter Found.";
        ucNewsletterListPager.DataBind();
    }
    protected void ucNewsletterListPager_PageIndexChanged(object sender, PagerEventArgs e)
    {
        BindNewsletterList(e.PageIndex);
    }
}